package model;

import java.util.ArrayList;

import controller.ByGroupController;

/**
 * Select only the contact in the group selected by the user and put them in an array to be displayed
 * @author Marie Morin
 *
 */
public class ByGroupModel {

	private ByGroupController c;
	private ArrayList<Contact> newContactsList= new ArrayList<Contact>();
	private String text;
	
	public ByGroupModel(ByGroupController c){

		this.c = c;
		
		if (c.getContactsList().size()>0){
			
			for (int i=0; i< c.getContactsList().size(); i++){


				if (this.c.getContactsList().get(i).getGroup().toLowerCase().contains(c.getText().toLowerCase()))
				{				
					newContactsList.add(c.getContactsList().get(i));
				}
			
			}
			
			c.setContactsList(newContactsList);
			
		}
		
			
		
	}

}
